import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'


import path from "path"

let _resolve = (dir) => {
  return path.resolve(dir)
}


export default ({ mode }) => {


  let env = loadEnv(mode, __dirname)
  
  return defineConfig({
    base: "./",
    plugins: [vue()],
    server: {
      port: 8080,
      proxy: {
        "/api": {
          target: env.VITE_BASE_URL,
          rewrite: path => path.replace(/^\/api/, "")
        }
      }
    },
   
    build:{
  
      outDir: path.resolve(env.VITE_MODE)
    },
    resolve: {
     
      alias: {
     
        "@": _resolve('src')
      }
    }
  })
}
